package tdg;

import java.util.ArrayList;
import java.util.List;

import modelgraph.ModelGraph;

public class TDependencyGraph
{
	private ModelGraph sourceModelGraph = null;
	private ModelGraph targetModelGraph = null;
	private List<TDependencyEdgeEqual> eedges = new ArrayList<TDependencyEdgeEqual>();
	private List<TDependencyEgdeCreate> cedges = new ArrayList<TDependencyEgdeCreate>();
	private List<TIntermediateNode> inodes = new ArrayList<TIntermediateNode>();
	
	public ModelGraph getSourceModelGraph()
	{
		return sourceModelGraph;
	}
	
	public void setSourceModelGraph(ModelGraph s)
	{
		sourceModelGraph = s;
	}
	
	public ModelGraph getTargetModelGraph()
	{
		return targetModelGraph;
	}
	
	public void setTargetModelGraph(ModelGraph t)
	{
		targetModelGraph = t;
	}
	
	public List<TDependencyEdgeEqual> getEEdges()
	{
		return eedges;
	}
	
	public List<TDependencyEgdeCreate> getCEdges()
	{
		return cedges;
	}
	
	public boolean addEEdge(TDependencyEdgeEqual e)
	{
		if (eedges.contains(e))
			return false;
		eedges.add(e);
		return true;
	}
	
	public boolean addCEdge(TDependencyEgdeCreate e)
	{
		if (cedges.contains(e))
			return false;
		cedges.add(e);
		return true;
	}
	
	public List<TIntermediateNode> getInodes()
	{
		return inodes;
	}
	
	public TIntermediateNode getINodeByName(String name)
	{
		for (TIntermediateNode inode : inodes)
		{
			if (inode.getName().equals(name))
				return inode;
		}
		return null;
	}
	
	public boolean addINode(TIntermediateNode i)
	{
		if (containsINode(i.getName()))
			return false;
		inodes.add(i);
		return true;
	}
	
	public boolean containsINode(String name)
	{
		for (TIntermediateNode in : inodes)
		{
			if (in.getName().equals(name))
				return true;
		}
		return false;
	}
}
